using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Drawing.Design;
using System.Drawing.Text;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Serialization.Formatters;
using System.Text;
using System.Windows.Forms.ComponentModel;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System;

namespace Workflows.Diagrams
{
    //internal class SelfHostToolboxItem
    //{
    //    private string componentClassName;
    //    private Type componentClass;
    //    private string name = null;
    //    private string className = null;
    //    private Image glyph = null;

    //    public SelfHostToolboxItem(string componentClassName)
    //    {
    //        this.componentClassName = componentClassName;
    //    }

    //    public string ClassName
    //    {
    //        get
    //        {
    //            if (className == null)
    //            {
    //                className = ComponentClass.FullName;
    //            }

    //            return className;
    //        }
    //    }

    //    public Type ComponentClass
    //    {
    //        get
    //        {
    //            if (componentClass == null)
    //            {
    //                componentClass = Type.GetType(componentClassName);
    //                if (componentClass == null)
    //                {
    //                    int index = componentClassName.IndexOf(",");
    //                    if (index >= 0)
    //                        componentClassName = componentClassName.Substring(0, index);

    //                    foreach (AssemblyName referencedAssemblyName in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
    //                    {
    //                        Assembly assembly = Assembly.Load(referencedAssemblyName);
    //                        if (assembly != null)
    //                        {
    //                            componentClass = assembly.GetType(componentClassName);
    //                            if (componentClass != null)
    //                                break;
    //                        }
    //                    }

    //                    //Finally check in Activities and ComponentModel dll
    //                    componentClass = typeof(SequentialWorkflowActivity).Assembly.GetType(componentClassName);
    //                    if (componentClass == null)
    //                        componentClass = typeof(CompositeActivity).Assembly.GetType(componentClassName);

    //                }
    //            }

    //            return componentClass;
    //        }
    //    }

    //    public string Name
    //    {
    //        get
    //        {
    //            if (name == null)
    //            {
    //                if (ComponentClass != null)
    //                    name = ComponentClass.Name;
    //                else
    //                    name = "Unknown Item";
    //            }

    //            return name;
    //        }
    //    }

    //    public virtual Image Glyph
    //    {
    //        get
    //        {
    //            if (glyph == null)
    //            {
    //                Type t = ComponentClass;

    //                if (t == null)
    //                    t = typeof(System.ComponentModel.Component);

    //                ToolboxBitmapAttribute attr = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(t)[typeof(ToolboxBitmapAttribute)];

    //                if (attr != null)
    //                    glyph = attr.GetImage(t, false);
    //            }
    //            return glyph;
    //        }
    //    }

    //    public override string ToString()
    //    {
    //        return componentClassName;
    //    }
    //}
}
